#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

// 分解质因数
vector<pair<int, int>> primeFactorization(int n) {
    vector<pair<int, int>> factors;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                cnt++;
                n /= i;
            }
            factors.push_back({i, cnt});
        }
    }
    if (n > 1) {
        factors.push_back({n, 1});
    }
    return factors;
}

int main() {
    int N, m1, m2;
    cin >> N >> m1 >> m2;
    
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    
    // 特殊情况：如果 m1 == 1，任何细胞在 0 秒都可以
    if (m1 == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    // 分解 m1 的质因数
    vector<pair<int, int>> m1_factors = primeFactorization(m1);
    
    int min_time = INT_MAX;
    bool found = false;
    
    // 检查每种细胞
    for (int i = 0; i < N; i++) {
        int s = S[i];
        int cell_time = 0;
        bool valid = true;
        
        // 检查该细胞是否包含 m1 的所有质因子
        for (auto& factor : m1_factors) {
            int prime = factor.first;
            int m1_exp = factor.second * m2;  // M 中该质因子的指数
            
            // 检查 s 是否包含该质因子
            if (s % prime != 0) {
                valid = false;
                break;
            }
            
            // 计算 s 中该质因子的指数
            int s_exp = 0;
            int temp = s;
            while (temp % prime == 0) {
                s_exp++;
                temp /= prime;
            }
            
            // 计算需要的时间：ceil(m1_exp / s_exp)
            int t = (m1_exp + s_exp - 1) / s_exp;
            cell_time = max(cell_time, t);
        }
        
        if (valid) {
            found = true;
            min_time = min(min_time, cell_time);
        }
    }
    
    if (found) {
        cout << min_time << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}